﻿using System;
using System.Collections.Generic;
using STeaL.Functional;

namespace STeaL.Algorithm {
  public static partial class ICollectionExtensions {
#region assign
    /// <summary>
    /// make a copy of 'items' into 'collection'
    /// </summary>
    public static void assign<T>(this ICollection<T> collection, IEnumerable<T> items) {
      collection.Clear();
      foreach (T item in items) collection.Add(item);
    }

    /// <summary>
    /// fill in 'collection' with 'n' 'items'
    /// </summary>
    public static void assign<T>(this ICollection<T> collection, int n, T item) {
      collection.Clear();
      while ( n-- > 0 ) collection.Add(item);
    }

#endregion
  }
}
